package com.utilsapi.CountTime;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;

import com.utilsapi.R;

public class CountTimeActivity extends AppCompatActivity implements TimeUtils.TimeListener{

    private CheckBox time1,time2,time3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_count_time);
        time1 = (CheckBox) findViewById(R.id.time1);
        time2 = (CheckBox) findViewById(R.id.time2);
        time3 = (CheckBox) findViewById(R.id.time3);

    }
    TimeUtils timeUtils1=null;
    TimeUtils timeUtils2=null;
    TimeUtils timeUtils3=null;
    public void onHhMMsss1(View view){
        if(((CheckBox)view).isChecked()) {
            timeUtils1 = new TimeUtils();
            timeUtils1.initTime(0, this);
        }else{
            timeUtils1.stopTime();
        }
    }
    public void onHhMMsss2(View view){
        if(((CheckBox)view).isChecked()) {
            timeUtils2 = new TimeUtils();
            timeUtils2.initTime(1, this);
        }else{
            timeUtils2.stopTime();
        }
    }
    public void onHhMMsss3(View view){
        if(((CheckBox)view).isChecked()) {
            timeUtils3 = new TimeUtils();
            timeUtils3.initTime(2, this);
        }else{
            timeUtils3.stopTime();
        }
    }

    @Override
    public void showTime(int type,String data) {
        if(type==0){
            time1.setText(data);
        }else if(type==1){
            time2.setText(data);
        }else if(type==2){
            time3.setText(data);
        }
        Log.e("tag","---------------------time= "+data);
    }
}
